package com.controller;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.mvc.SimpleFormController;
import com.model.Registration;
import com.service.RegistrationService;

public class SocietiesListController implements Controller {	

	private RegistrationService registrationService;

	public void setRegistrationService(RegistrationService registrationService) {
		this.registrationService = registrationService;
	}

	public SocietiesListController() {
		//		setCommandClass(Registration.class);
		//		setCommandName("registration");
	}

	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException {
		List<Registration> listSocieties= registrationService.listSocieties();

		Map<String, Object> myModel = new HashMap<String, Object>(); 
		myModel.put("societies", listSocieties);

		return new ModelAndView("home", "model", myModel);
	}
}